package Lab08.Q4;

//MyStack.java

import java.util.LinkedList;

public class MyStack<T> {
    private LinkedList<T> values = new LinkedList<T>();

    public void push(T t) {
        //Your code here
        values.addLast(t);
    }

    public T pull() {
        //Your code here
        return values.removeLast();
    }

    public T peak() {
        //Your code here
        return values.getLast();
    }

    public static void main(String[] args) {
        /* Your test code here */
        MyStack m = new MyStack();
        m.push(1);
        m.push('1');
        m.push(true);
        System.out.println("当前栈顶元素"+m.peak()+" 类型是："+m.peak().getClass());
        System.out.println("移除栈顶元素"+m.pull());
        System.out.println("当前栈顶元素"+m.peak()+" 类型是："+m.peak().getClass());
        System.out.println("移除栈顶元素"+m.pull());
        System.out.println("当前栈顶元素"+m.peak()+" 类型是："+m.peak().getClass());
        System.out.println("移除栈顶元素"+m.pull());
    }
}